<script setup lang="ts">
import { RouterView, useRoute } from 'vue-router'
import { computed, onMounted } from 'vue'
import { useUserStore } from '@/stores/counter'
import MainLayout from '@/components/MainLayout.vue'

const route = useRoute()
const userStore = useUserStore()

// 不需要布局的页面
const noLayoutPages = ['login', 'register', 'NotFound']
const showLayout = computed(() => !noLayoutPages.includes(route.name as string))

onMounted(() => {
  userStore.initUser()
})
</script>

<template>
  <div id="app">
    <transition name="fade" mode="out-in">
      <MainLayout v-if="showLayout" key="layout">
        <RouterView />
      </MainLayout>
      <div v-else key="auth" class="auth-container">
        <RouterView />
      </div>
    </transition>
  </div>
</template>

<style>
#app {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.auth-container {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  background-attachment: fixed;
}

/* 过渡动画 */
.fade-enter-active, .fade-leave-active {
  transition: opacity 0.3s ease;
}

.fade-enter-from, .fade-leave-to {
  opacity: 0;
}
</style>
